import React from 'react';
import { useNavigate } from 'react-router-dom'
import '../../styles/Booking Management/component/Top.scss'

import { notification, Button,Upload} from 'antd';

interface Props {
    title:string
}
function Top(props: Props) {
    let {title} = props
    // 1.上传状态发生改变的回调
    let handleuploadChange = (res: any) => {
        console.log(res)
        // if (res.file.status == 'done' && res.file.response.code == 200) {//上传成功
        //     message.success('上传成功！')
        // }
    }
    // 跳转增加页面路由
    let navigate = useNavigate();
    let toAddlist = () => {
        navigate("/index/bookingmanagement/addlist")
    }
    // 上传状态发生改变回调
    let handleUploadChange = (res: any) => {
        if (res.file.status == 'done' && res.file.response.code == 200) {
            notification.success({ message: '上传成功!' })
        }
    }
    return (
        <div>
            <div className='regis-top'>
                <span className='top-font'>{title}</span>
                {/* 发送到后端的文件名，data上传额外参数，设置回调函数，看到上传结果 */}
                {/* <Upload accept='.xls,.xlsx' action={'/api/custom/import'} name={"excel"} onChange={handleuploadChange}> */}
                <div className='top-right'>
                    <Button type="primary" onClick={toAddlist}>添加就诊人信息</Button>
                    <Upload accept='.xls,.xlsx' action='/api/custom/import' name="excel" onChange={handleUploadChange} showUploadList={false}>
                        <Button type="primary">导入</Button>
                    </Upload >
                    <Button type="primary" href='/api/custom/export'>导出</Button>
                    {/* <Button type="primary" href='/api/custom/export'>导出客户</Button> */}
                </div>
            </div>
        </div>
    );
}
interface Props {

}

export default Top